package cn.zhiwen.reflectController;

import cn.zhiwen.util.ReaderUtil;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo05 {

    /**
     * 通过读取配置文件完成反射
     * @param args
     */
    public static void main(String[] args) {
        try {
            Class aClass = Class.forName(ReaderUtil.getValuess("className"));
            Method methodName = aClass.getMethod(ReaderUtil.getValuess("methodName"),String.class);
            Object o = aClass.getConstructor().newInstance();
            Object invoke = methodName.invoke(o, "wuzhiwen");
            System.out.println(invoke);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}
